<template>
	<hyy-layout>
		<view class="my">
			<template v-if="token">
				<text class="name">{{ userInfo ? userInfo.userName :''}}</text>
				<view class="tag" v-if="userInfo">
					<fui-tag v-if="userInfo&&userInfo.roleName">{{userInfo? userInfo.roleName :''}}</fui-tag>
					<fui-tag v-if="userInfo&&userInfo.deptName">{{userInfo ? userInfo.deptName:''}}</fui-tag>
				</view>
			</template>
			<template v-else>
				<fui-button @click=" toLogin" width="200rpx">去登录</fui-button>
			</template>

			<view class="column" @click="clickColumnItem(item)" v-for="(item,index) in column" :key="index">
				<view class="icon-box" :style="`background-color:${item.iconBackgoundColor}`">
					<fui-icon :color="item.iconColor" :name="`icon-${item.icon}`" size="48rpx"
						customPrefix="iconfont"></fui-icon>
				</view>
				<text class="column-label">{{item.label}}</text>
			</view>

			<t-action-sheet id="t-action-sheet" bind:selected="handleSelected" />
		</view>
	</hyy-layout>

</template>

<script>
	import {
		MainPages
	} from '../../../../config/router-config'
	import {
		mapState,
		mapActions,
		mapGetters
	} from 'pinia'
	import {
		useAuthStore
	} from '../../../../store/modules/auth'
	import {
		useSyStemStore
	} from '../../../../store/modules/system'
	import {
		useHandleWorkOrder
	} from '../../../../store/modules/handleWorkOrder'
	import {
		useDeptStore
	} from '../../../../store/modules/dept'
	import {
		useHandleWorkOrder_ChargeBack
	} from '../../../../store/modules/handleWorkOrder_ChargeBack'
	import {
		useHandleWorkOrder_Cooperation
	} from '../../../../store/modules/handleWorkOrder_cooperation'
	import {
		useHandleWorkOrder_Eva
	} from '../../../../store/modules/handleWorkOrder_Eva'
	import {
		useHandleWorkOrder_Handle
	} from '../../../../store/modules/handleWorkOrder_Handle'
	import {
		useHandleWorkOrder_Pause
	} from '../../../../store/modules/handleWorkOrder_Pause'
	import {
		useHandleWorkOrder_Termination
	} from '../../../../store/modules/handleWorkOrder_Termination'
	import {
		useHandleWorkOrder_Transfer
	} from '../../../../store/modules/handleWorkOrder_Transfer'
	import {
		useHandleWorkOrder_Upgrade
	} from '../../../../store/modules/handleWorkOrder_Upgrade'
	import {
		useSelectUserPageStore
	} from '../../../../store/modules/selectUserPage'
	import {
		useTeamStore
	} from '../../../../store/modules/team'
	import {
		useTeamUserStore
	} from '../../../../store/modules/teamUser'
	import {
		useWorkOrderSearh
	} from '../../../../store/modules/worderSerach'
	import {
		useWorkOrderReview
	} from '../../../../store/modules/workOrderReview'
	import {
		useWx
	} from '../../../../store/modules/wx'
	import {
		useDictStore
	} from '../../../../store/modules/dic'
	import {
		useHandleWorkOrder_Complete
	} from '../../../../store/modules/handleWorkOrder_Complete'
	import {
		useReportStore
	} from "@/store/modules/report.js"
	export default {
		computed: {
			...mapState(useAuthStore, ['token']),
			...mapGetters(useAuthStore, ['userInfo']),
		},
		data() {
			return {
				column: [
					// {
					// 	icon: 'shuaxin',
					// 	label: '切换角色',
					// 	iconColor: '#D54941',
					// 	iconBackgoundColor: '#FFF0ED',
					// 	fn: 'switchRole'
					// },
					{
						icon: 'dasao',
						label: '清除缓存',
						iconColor: '#E37318',
						iconBackgoundColor: '#FFF1E9',
						fn: 'clearStorage'

					},
					// {
					// 	icon: 'wenben',
					// 	label: '隐私协议',
					// 	iconColor: '#2BA471',
					// 	iconBackgoundColor: '#E3F9E9',
					// 	fn: 'clearStorage'

					// }
				]
			}
		},
		created() {
			this.getUserInfo()
		},
		methods: {
			...mapActions(useAuthStore, ['getUserInfo']),
			toLogin() {
				uni.navigateTo({
					url: MainPages.LOGIN.router
				})
			},
			clickColumnItem(item) {
				this[item.fn]()
			},
			clearStorage() {
				uni.showModal({
					title: '提示',
					content: '清除缓存会退出登陆状态,是否继续?',
					success: function(res) {
						if (res.confirm) {
							useAuthStore().$reset()
							useHandleWorkOrder().$reset()
							useSyStemStore().$reset()
							useTeamStore().$reset()
							useTeamUserStore().$reset()
							useWorkOrderSearh().$reset()
							useDeptStore().$reset()
							useDictStore().$reset()
							useWx().$reset()
							useWorkOrderReview().$reset()
							useHandleWorkOrder_ChargeBack().$reset()
							useHandleWorkOrder_Complete().$reset()
							useHandleWorkOrder_Cooperation().$reset()
							useHandleWorkOrder_Eva().$reset()
							useHandleWorkOrder_Handle().$reset()
							useHandleWorkOrder_Pause().$reset()
							useHandleWorkOrder_Termination().$reset()
							useHandleWorkOrder_Transfer().$reset()
							useHandleWorkOrder_Upgrade().$reset()
							useHandleWorkOrder().$reset()
							useReportStore().$reset()
							useSelectUserPageStore().$reset()

						} else if (res.cancel) {
							console.log('用户点击取消');
						}


					},


				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.my {
		padding: 30rpx;
	}

	.name {
		font-size: 56rpx;
		font-weight: 600;
		color: rgba(0, 0, 0, 0.9);
	}

	.tag {
		margin-top: 32rpx;
	}

	.t {
		&-tag {
			&-class {
				margin-left: 16rpx;
			}
		}
	}

	.column {
		margin-top: 64rpx;
		padding: 24rpx 32rpx;
		background: #ffffff;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		display: flex;
		align-items: center;

		&+& {
			margin-top: 16rpx;
		}

		&-label {
			font-size: 32rpx;
			font-weight: 400;
			color: rgba(0, 0, 0, 0.9);
			margin-left: 24rpx;
		}

		.icon {
			&-box {
				display: inline-block;
				padding: 12rpx;
				background: #fff0ed;
				border-radius: 12rpx 12rpx 12rpx 12rpx;
				opacity: 1;
			}
		}
	}
</style>